$(function(){
	//Create image gallery
	var shtml = "";
	var thtml = "";
	for(i=1;i<=18;i++){
		shtml +=
			"<li>" +
			"<a href='" + base_url + "img/gallery/" + i + ".jpg'>" +
			"<img class='thumb' src='" + base_url + "img/gallery/" + i + ".jpg' />" +
			"</a>" +
			"</li>";
		
		if(i%5==1) thtml += "<tr>";
		thtml += "<td><a href='" + base_url + "img/gallery/" + i + ".jpg' class='nyroModal'  rel='gal'><img class='thumb' src='" + base_url + "img/gallery/" + i + ".jpg' /><a></td>";
		if(i%5==0 || i==18) thtml += "</tr>";
	}
	$('ul.ad-thumb-list').html(shtml);
	$('.tile-gallery table').html(thtml);
	
	var galleries = $('.ad-gallery').adGallery({
	  loader_image: base_url + 'img/ad-gallery/loader.gif',
	  width: 600,
	  height: 400,
	  thumb_opacity: 0.7,
	  start_at_index: 0, 
	  animate_first_image: false, // Should first image just be displayed, or animated in?
	  animation_speed: 400, // Which ever effect is used to switch images, how long should it take?
	  display_next_and_prev: true, // Can you navigate by clicking on the left/right on the image?
	  display_back_and_forward: true, // Are you allowed to scroll the thumb list?
	  scroll_jump: 0, // If 0, it jumps the width of the container
	  slideshow: {
		enable: true,
		autostart: true,
		speed: 3000,
		start_label: 'Start',
		stop_label: 'Stop',
		stop_on_scroll: true,
		countdown_prefix: '(',
		countdown_sufix: ')',
	  },
	  effect: 'fade',
	  enable_keyboard_move: true,
	  cycle: true
	});
	
	$('.nyroModal').nyroModal();
	
	$('#tile').click(function(){
		$('#tile').css('background-color','#dedcdc');
		$('#slide').css('background-color','#f3f3f3');
		
		$('.ad-gallery').hide('slow');
		$('.tile-gallery').show('slow');
	});
	
	$('#slide').click(function(){
		$('#tile').css('background-color','#f3f3f3');
		$('#slide').css('background-color','#dedcdc');
		
		$('.tile-gallery').hide('slow');
		$('.ad-gallery').show('slow');
	});
});